# -*- coding:utf-8 -*-
# created by jinss

import sys

print(sys.argv)

old_str = sys.argv[1]
new_str = sys.argv[2]
filename = sys.argv[3]

f = open(filename, mode="r+", encoding="utf-8")
data = f.read()

old_str_count = data.count(old_str)

new_data = data.replace(old_str, new_str)

f.seek(0)
f.truncate()

f.write(new_data)

print(f"成功替换字符'{old_str}' to '{new_str}', 共{old_str_count}处...")